package cn.cs.message.tempstorage.disk;

import java.nio.ByteBuffer;

import cn.cs.message.Message;
import cn.cs.message.MessageClient;

public class MsgDecoder 
{
	public static final int HEAD_SIZE=4;
	private int size;
	
	public int size()
	{
		return size;
	}
	
	public MsgDecoder(ByteBuffer buffer)
	{
		this.size=buffer.getInt();
	}
	
	public Message decode(ByteBuffer buffer)
	{
		byte[] content=new byte[size];
		buffer.get(content);
		return MessageClient.getFromBytes(content);
	}
}
